package com.late13.myapplication;

import android.content.ContentValues;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    public static final String MAIN_TAG = "Task_";
    private static final String TAG = MAIN_TAG + "Main";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d(TAG, "activity created!");
        setContentView(R.layout.main_layout);
        Log.d(TAG, "main_layout set!");

        createDb();

        Button btn_edit = (Button)findViewById(R.id.button_editor);
        final Button btn_task = (Button)findViewById(R.id.button_task);
        Log.d(TAG, "buttons found!");

        btn_edit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d(TAG, "button_edit clicked!");
//                Toast.makeText(MainActivity.this,"按钮2 按下了！", Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(MainActivity.this, Editor.class);
                startActivity(intent);
                Log.d(TAG, "Editor started!");
            }
        });

        btn_task.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.d(TAG, btn_task.getId() + " clicked!");
                Intent intent = new Intent(MainActivity.this, TasksActivity.class);
                startActivity(intent);
                Log.d(TAG, "TasksActivity start!");
            }
        });
    }

    private void createDb() {
        Log.d(TAG, "准备打开数据库！");
        Log.v(TAG, "如果数据库没有数据，向数据库添加初始数据");

    }

    public Boolean DBHasData(SQLiteDatabase database) {
        Log.v(TAG, "准备查看数据库是否有数据");
        return false;
    }
}
